Correct 32on64 handling of VCPUOP_register_runstate_memory_area. We
authorIan Campbell <ian.campbell@xensource.com>
Fri, 25 May 2007 14:28:52 +0000 (15:28 +0100)
committerIan Campbell <ian.campbell@xensource.com>
Fri, 25 May 2007 14:28:52 +0000 (15:28 +0100)
were copying too many bytes from the guest so the test for
area.addr.h.c != area.addr.p was failing.

Added a WARN_ON to the kernel to catch this case. It would be a BUG_ON
but this would break the new kernel on older hypervisors and the only
real problem is that stolen time is not updated, which we can live
with.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c
linux-2.6-xen-sparse/arch/ia64/kernel/time.c
xen/arch/x86/x86_64/domain.c

index c19008a6bfb7be264ab29adf2a32a9fe78b26428..b2ffaa920c094da2fb0b655915ba2151e3253632 100644 (file)
@@ -732,11 +732,13 @@ static void init_missing_ticks_accounting(int cpu)
 {
        struct vcpu_register_runstate_memory_area area;
        struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
+       int rc;
 
        memset(runstate, 0, sizeof(*runstate));
 
        area.addr.v = runstate;
-       HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu, &area);
+       rc = HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu, &area);
+       WARN_ON(rc && rc != -ENOSYS);
 
        per_cpu(processed_blocked_time, cpu) =
                runstate->time[RUNSTATE_blocked];
index cec97e3069f4913022e985d5c2838563cd394c76..b73cffa94fe08e09d8b87811e13c79e82d81d490 100644 (file)
@@ -257,11 +257,13 @@ static void init_missing_ticks_accounting(int cpu)
 {
        struct vcpu_register_runstate_memory_area area;
        struct vcpu_runstate_info *runstate = &per_cpu(runstate, cpu);
+       int rc;
 
        memset(runstate, 0, sizeof(*runstate));
 
        area.addr.v = runstate;
-       HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu, &area);
+       rc = HYPERVISOR_vcpu_op(VCPUOP_register_runstate_memory_area, cpu, &area);
+       WARN_ON(rc && rc != -ENOSYS);
 
        per_cpu(processed_blocked_time, cpu) = runstate->time[RUNSTATE_blocked];
        per_cpu(processed_stolen_time, cpu) = runstate->time[RUNSTATE_runnable]
index 775e536f4d47e8f55640e8d5d2227a837e55712e..48cfec742391cd5e4beeffd432d8abab78288ba1 100644 (file)
@@ -22,8 +22,10 @@ arch_compat_vcpu_op(
         struct compat_vcpu_register_runstate_memory_area area;
         struct compat_vcpu_runstate_info info;
 
+        area.addr.p = 0;
+
         rc = -EFAULT;
-        if ( copy_from_guest(&area, arg, 1) )
+        if ( copy_from_guest(&area.addr.h, arg, 1) )
             break;
 
         if ( area.addr.h.c != area.addr.p ||